package _99练习;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

<<<<<<< HEAD
/**
 * @author ZhiCheng Qian
 * @since 2021/11/30 10:35
 */
=======

>>>>>>> 1c69d32fc055e0010098b09f71795769d9a12acd
public class GetUp implements Runnable {

	Lock l = new ReentrantLock();

	// 他们早上起来要干6件事:起床穿衣服,刷牙,洗脸,上大号,吃早饭，整理物品

	public void dress() {
		System.out.println(Thread.currentThread().getName() + "起床穿衣服");

		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public void brushTeeth() {
		System.out.println(Thread.currentThread().getName() + "刷牙");

		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public void washingFace() {
		System.out.println(Thread.currentThread().getName() + "洗脸");

		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public static synchronized void restroom() {
		System.out.println(Thread.currentThread().getName() + "上大号");

		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public void haveBreakfast() {
		System.out.println(Thread.currentThread().getName() + "吃早饭");

		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public void organizeGoods() {
		System.out.println(Thread.currentThread().getName() + "整理东西");

		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void run() {
		dress();
		brushTeeth();
		washingFace();
		restroom();
		haveBreakfast();
		organizeGoods();

		System.out.println(Thread.currentThread().getName() + "执行完所有任务");
	}
}
